import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/home',
            name: 'home',
            component: () => import('@/views/home.vue'),
            meta: { isshow: true }
        },
        {
            path: '/login',
            name: 'login',
            component: () => import('@/views/Login.vue'),
        },
        {
            path: '/contact',
            name: 'contact',
            component: () => import('@/views/ContactList.vue'),
            meta: { isshow: true }
        },
        //发现页
        {
            path: '/find',
            name: 'find',
            component: () => import('@/views/finds/find.vue'),
            meta: { isshow: true }
        },
        {
            path: '/pron',
            name: 'pron',
            component: () => import('@/views/wore/pron.vue'),
            meta: { isshow: true }
        },
        //添加朋友页面
        {
            path: '/friend',
            name: 'friend',
            component: () => import('@/views/finds/Friend.vue'),
            meta: { isshow: false }
        },
        //朋友页
        {
            path: '/searfriend',
            name: 'searfriend',
            component: () => import('@/views/finds/searFriend.vue'),
            meta: { isshow: false }
        },
        //收付款
        {
            path: '/collection',
            name: 'collection',
            component: () => import('@/views/finds/collection.vue'),
            meta: { isshow: false }
        },
        //自定义列表页
        {
            path: '/getuser',
            name: 'getuser',
            component: () => import('@/views/finds/getuser.vue'),
            meta: { isshow: false }
        },
        //个人收款页
        {
            path: '/qrcode',
            name: 'qrcode',
            component: () => import('@/views/finds/Qrcode.vue'),
            meta: { isshow: false }
        },
        {
            path: '/addfriend',
            name: 'addfriend',
            component: () => import('@/views/finds/RadarAddFriend.vue'),
            meta: { isshow: false }
        },
        {
            path: '/scan',
            name: 'scan',
            component: () => import('@/views/finds/scan.vue'),
            meta: { isshow: false }
        },
        {
            path: '/',
            redirect: '/login',
            meta: { isshow: false }
        },
        {
            path: '/friendDetail/:id',
            name: 'friendDetail',
            component: () => import('@/views/FriendDetails.vue'),
            meta: { isshow: false }
        },
    ]
})
// 路由守卫
// router.beforeEach((to, from, next) => {
//     if (to.path === '/login') {
//         next()
//     } else if (localStorage.getItem('access_token')) {
//         next()
//     } else {
//         next('/login')
//     }
// })
export default router